package com.nifostasky.blog.controller;



import com.nifostasky.entity.User;
import com.nifostasky.service.impl.UserAnnotationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户表(User)表控制层
 *
 * @author makejava
 * @since 2021-09-26 11:08:49
 */
@RestController
@RequestMapping("/userAnnotation")
public class UserAnnotationController {
    @Autowired
    @Qualifier("userAnnotationService")
    private UserAnnotationServiceImpl userAnnotationService;

    @GetMapping("/queryAll")
    public List<User> queryAll() {
        return userAnnotationService.queryAll();
    }

    @GetMapping("/getUserInfo/{userId}")
    public User getUserInfo(@PathVariable Long userId) {
        User userInfo = userAnnotationService.getUserInfo(userId);
        return userInfo;
    }

    @PostMapping("/add")
    public String add(@RequestBody User user) {
        userAnnotationService.add(user);
        return "新增成功～";
    }

    @PostMapping("/update")
    public String update(@RequestBody User user) {
        userAnnotationService.update(user);
        return "更新成功～";
    }

    @GetMapping("/delete/{userId}")
    public String delete(@PathVariable Long userId) {
        userAnnotationService.delete(userId);
        return "删除成功～";
    }
}
